package cn.getech.data.metadata.constant;

import cn.getech.data.intelligence.common.utils.NameValue;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public enum WeekEnum {
    Mon(1, "周一"),
    Tue(2, "周二"),
    Wed(3, "周三"),
    Thu(4, "周四"),
    Fri(5, "周五"),
    Sat(6, "周六"),
    Sun(0, "周日"),
    ;
    private Integer value;
    private String desc;

    WeekEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String getWeekDay(Integer value){
        for (WeekEnum we : WeekEnum.values()) {
            if(we.getValue().intValue() == value.intValue())
                return we.toString();
        }
        return null;
    }

    public static String getWeek(Integer value){
        for (WeekEnum we : WeekEnum.values()) {
            if(we.getValue().intValue() == value.intValue())
                return we.getDesc();
        }
        return null;
    }

    public static List<NameValue<Integer>> getList() {
        List<NameValue<Integer>> list = new ArrayList<>();
        for (WeekEnum value : WeekEnum.values()) {
            NameValue<Integer> nv = new NameValue<>();
            nv.setName(value.getDesc());
            nv.setValue(value.getValue());
            list.add(nv);
        }
        return list;
    }
}
